package com.xs.creat;

import java.util.Random;
import java.util.Scanner;

public class ArrayDemo4 {
    //从控制台输入5个数，给5个数随便排列
    public static void main(String[] args) {
        int[] a=new int[5];
        Scanner sc1=new Scanner(System.in);
        for (int i=0;i<a.length;i++){
            System.out.println("第"+(i+1)+"数");
            int b=sc1.nextInt();
            a[i]=b;
        }
        System.out.println("你所输入的数为：");
        for (int i=0;i<a.length;i++){
            System.out.print(a[i]+"  ");
        }
        System.out.println("\n");
        Random r=new Random();
        for (int i=0;i<a.length;i++){
            int c=r.nextInt(a.length);
            int temp=a[c];
            a[c]=a[i];
            a[i]=temp;
        }
        System.out.println("将数组随机排列后的结果：");
        for (int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
        }
    }

}
